package com.timebank.websocket.controller;

import com.timebank.common.core.web.controller.BaseController;
import com.timebank.common.core.web.page.TableDataInfo;
import com.timebank.common.core.web.pojo.AjaxResult;
import com.timebank.common.security.annotation.RequiresLogin;
import com.timebank.websocket.pojo.vo.SendMsgVO;
import com.timebank.websocket.service.WSMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * websocket消息 控制层
 * @author shiliuyinzhen
 */
@RestController
@RequestMapping("/wsMessage")
@Api(tags = "websocket消息相关接口")
public class WebSocketMessageController extends BaseController {
    @Resource
    private WSMessageService wsMessageService;

    /**
     * 查询历史消息
     * @param sendMsgVO
     * @return
     */
    @RequiresLogin
    @GetMapping("/list")
    @ApiOperation("查询历史消息")
    public TableDataInfo getWSMessageList(SendMsgVO sendMsgVO){
        startPage();
        List<SendMsgVO> list = wsMessageService.getWSMessageList(sendMsgVO);
        return getDataTable(list);
    }

    /**
     * 批量确认消息
     * @return
     */
    @RequiresLogin
    @PostMapping("/confirm/{messageIds}")
    @ApiOperation("批量确认消息")
    public AjaxResult batchConfirmMessage(@PathVariable("messageIds") String[] messageIds){
        return wsMessageService.batchConfirmWSMessage(messageIds);
    }
}
